**Specify your working directory in Stata.
cd c:\data\2022ConsCourt\

**We use "type double" for our data accuracy because double preserves 16 digits of accuracy. As such, do not "compress" our data when replicating our analyses.
set type double

use KimNolettePOPAnalysis, clear

sort iso2 year
save KimNolettePOPAnalysis, replace

**Table OA1: Summary Statistics

summ commonlaw VCengage ///
     polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 if event~=.

	 
**Stset: Our data are already stset as per the following.

stset ifinish, failure(event) exit(time .) enter(istart)
	  
**Model 1 in Table 1: Main Model in the article

stcox commonlaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
	  , cluster(id) efron nohr nolog

	  
**Table OA2: Proportionality Test
 
estat phtest, rank detail

est drop _all


**Model 2 in Table 1: Europe

stcox commonlaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
	  europe ///
	  , cluster(id) efron nohr nolog

	  
**Model 3 in Table 1: the former Soviet Union

stcox commonlaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
	  soviet ///
	  , cluster(id) efron nohr nolog

********************************************************************************	  
**Robustness Checks against Endogeneity Bias Part II

**Model 1 in Table OA4: Between-Within Random-Effects Logit

melogit event commonlaw m_VCengage d_VCengage ///
      m_polinsur d_polinsur m_RoverG d_RoverG m_dt3yrs d_dt3yrs ///
	  m_v2xnp_pres12 d_v2xnp_pres12 m_lnlatent_gdppcWB22 d_lnlatent_gdppcWB22 ///
	  || id:, vce(cluster id) nolog

**Model 2 in Table OA4: Between-Within Random-Effects Logit with Temporal Dependence	  
	  
melogit event commonlaw m_VCengage d_VCengage ///
      m_polinsur d_polinsur m_RoverG d_RoverG m_dt3yrs d_dt3yrs ///
	  m_v2xnp_pres12 d_v2xnp_pres12 m_lnlatent_gdppcWB22 d_lnlatent_gdppcWB22 ///
	  t1 t2 t3 || id:, vce(cluster id) nolog 	

	  
**Robustness Checks against Endogeneity Bias Part III
**Models 1 & 2 in Table OA5: Two-Stage Model: Maddala's (1983) Control Function Approach

**Model 1 in Table OA5: First-Stage Equation
probit VCengage upopfixpct islmsunpct VCleaderlji17join ihs_distWashDCkm ///
	   commonlaw polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22, cluster(id)   

**Instrument Relevance Test	   
test upopfixpct islmsunpct VCleaderlji17join ihs_distWashDCkm
	   
predict xb1, xb
gen mylambda = normalden(xb1) / normal(xb1) if VCengage==1
replace mylambda = -normalden(xb1) / (1- normal(xb1)) if VCengage==0	   

**Model 2 in Table OA5: Second-Stage Equation	   
probit event commonlaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
      mylambda t1 t2 t3, cluster(id)
	  
**Table OA6: Instrument Exogeneity Test		 
predict xb2, xb
gen resid=cond(event==1, normalden(xb2)/normal(xb2), -normalden(xb2)/(1-normal(xb2)))
		 
reg resid upopfixpct islmsunpct VCleaderlji17join ihs_distWashDCkm ///
	commonlaw polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
	, cluster(id)

drop xb1 xb2 mylambda resid		 

**Bootstrap Standard Errors (SEs) for Model 2 in Table OA5: Second-Stage Equation
program maddalatwostep, eclass
marksample conscourt
tempname b V
tempvar xb
capture drop mylambda
probit VCengage upopfixpct islmsunpct VCleaderlji17join ihs_distWashDCkm ///
	   commonlaw polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22, cluster(id)
predict `xb', xb
gen mylambda = normalden(`xb') / normal(`xb') if VCengage==1
replace mylambda = -normalden(`xb') / (1- normal(`xb')) if VCengage==0	   
probit event commonlaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
      mylambda t1 t2 t3, cluster(id)	   
matrix `b' = e(b)
ereturn post `b', esample(`conscourt')
end

**Use only the bootstrap-cluster SEs and p-values
bootstrap _b, reps(2000) seed(12345) cluster(id) idcluster(newid) group(id) nodots, if event~=.: maddalatwostep	  

drop newid mylambda	
program drop _all


********************************************************************************		 
**Robustness Checks against Omitted Variable Bias Part I

**Stset: Our data are already stset as per the following.

stset ifinish, failure(event) exit(time .) enter(istart)

**Model 1 in Table OA7: ABA ROLI	  

stcox commonlaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
	  ABAengage ///
	  , cluster(id) efron nohr nolog

**Model 2 in Table OA7: Federalism (POLCON 2021) 

stcox commonlaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
	  federal_polcon ///
	  , cluster(id) efron nohr nolog	  

**Model 3 in Table OA7: Judicial Independence	  

stcox commonlaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
	  lji20170321 ///
	  , cluster(id) efron nohr nolog

**Model 4 in Table OA7: V-Dem 12 Polyarchy

stcox commonlaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
	  v2x_polyarchy12 ///
	  , cluster(id) efron nohr nolog
	  
**Model 5 in Table OA7: Cultural Globalization (KOF 2021)	  

stcox commonlaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
	  KOFCuGI ///
	  , cluster(id) efron nohr nolog	  


********************************************************************************		 
**Robustness Checks against Alternative Operationalization of Control Variables	  
	  
**Model 1 in Table OA8: Regional Density (RoverG replaced by Rpct)

stcox commonlaw VCengage ///
      polinsur dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
	  Rpct ///
	  , cluster(id) efron nohr nolog

**Model 2 in Table OA8: Democratic Transition within 1 Year (dt3yrs replaced by dt1yrs)

stcox commonlaw VCengage ///
      polinsur RoverG v2xnp_pres12 lnlatent_gdppcWB22 ///
	  dt1yr ///
	  , cluster(id) efron nohr nolog

**Model 3 in Table OA8: Democratic Transition within 5 Years (dt3yrs replaced by dt5yrs)  
	  
stcox commonlaw VCengage ///
      polinsur RoverG v2xnp_pres12 lnlatent_gdppcWB22 ///
	  dt5yrs ///
	  , cluster(id) efron nohr nolog

**Model 4 in Table OA8: Democratic Transition within 10 Years (dt3yrs replaced by dt10yrs)  
	  
stcox commonlaw VCengage ///
      polinsur RoverG v2xnp_pres12 lnlatent_gdppcWB22 ///
	  dt10yrs ///
	  , cluster(id) efron nohr nolog

	  
********************************************************************************		 
**Robustness Checks against Omitted Variable Bias Part II	 
	  
**Model 1 in Table OA9: agreeRUS	  

stcox commonlaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
	  agreeRUS ///
	  , cluster(id) efron nohr nolog

**Model 2 in Table OA9: agreeCHN

stcox commonlaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
	  agreeCHN ///
	  , cluster(id) efron nohr nolog

**Model 3 in Table OA9: Regional Dictatorship Percentage

stcox commonlaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
	  Rdictpct ///
	  , cluster(id) efron nohr nolog

**Model 4 in Table OA9: Regional Dictatorship Reverse Polyarchy

stcox commonlaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
	  Rrvse_poly ///
	  , cluster(id) efron nohr nolog
	  
**Model 5 in Table OA9: Regional Dictatorship Reverse Judicial Constraint

stcox commonlaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
	  Rrvse_jucon ///
	  , cluster(id) efron nohr nolog
	  
**Model 6 in Table OA9: Regional Dictatorship Reverse Rule of Law

stcox commonlaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
	  Rrvse_rule ///
	  , cluster(id) efron nohr nolog

**Model 7 in Table OA9: Regional Dictatorship Reverse Latent Judicial Independence

stcox commonlaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
	  Rrvse_lji ///
	  , cluster(id) efron nohr nolog	  

clear 
exit
